﻿using D.Medicalcare.ErrorCode;
using D.Medicalcare.Write.API.Application.Commands.HospitalNavigationCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Write.API.Controllers
{
    /// <summary>
    /// 医院导航控制器-写入接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HospitalNavigationController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public HospitalNavigationController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加医院导航
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddHospitalNavigation(AddHospitalNavigationCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除医院导航
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DeletedHospitalNavigation([FromQuery]DeletedHospitalNavigationCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }   
        }
        /// <summary>
        /// 更新医院导航
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateHospitalNavigation(UpdateHospitalNavigationCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
